(:
  A procedure to number all items in a Display file
  It suppresses any previous numbering
:)
declare boundary-space strip;
import module namespace
    jj = "http://kumquat.emse.fr/utilitaires"
    at "jjutils.xq" ;
<display>{
let $t := $arguments[1]
let $facet := $arguments[2]
let $d := doc($t)/display/item
for $e at $p in $d
let $count := fn:count(fn:tokenize(jj:get-text($e/info[@name=$facet])," "))
return
  <item>{
    <info>{ 
    	attribute name {fn:string-join(("word","count"),"-")},
    	xs:string($count)
    }</info>,
    (  let $inf := $e/info
       for $i in $inf
       return
         if ($i[name=fn:string-join(("word","count"),"-")]) then
             ()
         else
             $i
    )
  }</item>
}</display>
